<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/layui.css">
</head>
<body style="margin-top: 50px; margin-left: 10px">
<div class="form-content">
    <form id="form-add" class="form-horizontal">
        <div class="form-group">
            <label class="col-xs-3 control-label">试卷名</label>
            <div class="col-xs-8">
                <input  type="text" name="examName"  placeholder="请输入试卷名" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-3 control-label">考试时间</label>
            <div class="col-xs-8">
                <input type="text" name="examStartDate" class="layui-input" id="examDate" autocomplete="off" >
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-3 control-label">考试持续时间</label>
            <div class="col-xs-8">
                <input type="number" name="examLastTime" class="layui-input" autocomplete="off" >
            </div>
        </div>
        <div class="form-group" >
            <input type="submit" class="layui-input" style="margin: auto" value="提交">
        </div>
    </form>
</div>

<link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/bootstrap.min.css">
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
<script src="/static/js/common.js"></script>
<script src="${pageContext.request.contextPath}/static/layui.all.js"></script>
<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#examDate', //指定元素
            type: 'datetime'
        });
    });
    $("#form-add").submit(function () {
        var data = $.opData.getFormJson("#form-add")
        console.log("dada:" + JSON.stringify(data))
        $.operate.jsonPost('/admin/online/examAdd', data, function (res) {
            console.log("成功：" + JSON.stringify(res))
            if (res.code == 0) {
                //成功
                $.myLayui.closeLayerAndRfresh()

            } else {
                alert("添加失败")
                return false
            }
        })
        return false;
    })

</script>
</body>
</html>
